package com.xie.leetcode.array;

//453. 最小操作次数使数组元素相等
//        给你一个长度为 n 的整数数组，每次操作将会使 n - 1 个元素增加 1 。返回让数组所有元素相等的最小操作次数。
//
//
//
//        示例 1：
//
//        输入：nums = [1,2,3]
//        输出：3
//        解释：
//        只需要3次操作（注意每次操作会增加两个元素的值）：
//        [1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]
//        示例 2：
//
//        输入：nums = [1,1,1]
//        输出：0
//
//
//        提示：
//
//        n == nums.length
//        1 <= nums.length <= 105
//        -109 <= nums[i] <= 109
//        答案保证符合 32-bit 整数

import java.util.Arrays;

/**
 * @author xiezhendong
 * @date 2021/10/26
 */
public class MinMoves {

    public static void main(String[] args) {
        MinMoves minMoves = new MinMoves();
        System.out.println(minMoves.minMoves(new int[]{1, 2, 3}));
        System.out.println(minMoves.minMoves(new int[]{1}));
        System.out.println(minMoves.minMoves(new int[]{1, 1000000000}));
        System.out.println(minMoves.minMoves(new int[]{659, 552, 678, 856, 300, 414, 0, 721, 810, 819,
                229, 299, 247, 86, 895, 598, 954, 543, 397, 828, 394, 836, 641, 560, 271, 464,
                693, 804, 942, 246, 245, 601, 150, 923, 810, 802, 337, 810, 523, 147, 982, 104,
                798, 229, 542, 46, 827, 496, 589, 577, 676, 335, 413, 317, 896, 37, 782, 941, 841,
                76, 539, 438, 29, 689, 361, 839, 491, 698, 2, 366, 197, 336, 470, 348, 565, 12,
                394, 745, 861, 335, 322, 537, 671, 87, 855, 919, 124, 989, 860, 317, 65, 751,
                755, 446, 792, 468, 286, 635, 166, 640, 1, 716, 976, 823, 416, 541, 187, 810,
                638, 48, 145, 312, 586, 168, 400, 793, 87, 876, 782, 299, 546, 199, 50, 653,
                645, 194, 122, 283, 829, 640, 923, 182, 708, 899, 5, 124, 793, 545, 934, 783,
                593, 432, 96, 179, 600, 496, 324, 40, 724, 106, 339, 622, 657, 742, 276, 655,
                936, 750, 938, 118, 742, 214, 300, 451, 465, 658, 575, 610, 203, 862, 394, 796,
                646, 490, 328, 598, 338, 652, 638, 414, 111, 978, 37, 768, 720, 665, 775, 8,
                767, 714, 126, 509, 280, 427, 960, 745, 437, 888, 356, 640, 750, 750, 788, 748,
                240, 116, 346, 930, 121, 985, 344, 584, 963, 381, 704, 35, 46, 480, 43, 813, 546,
                522, 675, 826, 949, 635, 571, 386, 875, 927, 378, 977, 29, 166, 725, 621, 635, 72,
                551, 108, 57, 896, 692, 372, 629, 396, 759, 676, 876, 154, 841, 422, 676, 868, 248,
                625, 504, 820, 363, 731, 99, 93, 709, 481, 260, 434, 102, 247, 506, 654, 355, 915, 902,
                47, 639, 531, 443, 398, 559, 320, 553, 753, 94, 581, 621, 343, 559, 477, 515, 922, 209, 966,
                16, 918, 447, 628, 352, 550, 875, 211, 556, 230, 478, 458, 629, 470, 989, 72, 220, 549, 744,
                125, 302, 839, 707, 923, 534, 266, 401, 49, 540, 962, 367, 908, 880, 815, 536, 584, 717, 763,
                147, 273, 345, 978, 731, 974, 448, 720, 399, 20, 621, 143, 146, 275, 982, 853, 199, 868, 471,
                952, 917, 11, 266, 637, 272, 146, 452, 160, 82, 169, 924, 582, 794, 621, 560, 525, 596, 360,
                597, 347, 380, 571, 490, 526, 846, 825, 731, 397, 693, 554, 349, 963, 918, 615, 600, 190, 113,
                404, 350, 548, 925, 274, 130, 719, 248, 690, 596, 196, 50, 545, 543, 782, 116, 33, 661, 963, 210,
                392, 360, 904, 299, 62, 219, 217, 29, 171, 407, 495, 575, 757, 43, 500, 384, 173, 571, 632, 215,
                167, 828, 265, 64, 723, 399, 181, 756, 60, 496, 967, 805, 208, 223, 104, 622, 442, 321, 652, 965,
                728, 499, 540, 837, 542, 392, 221, 67, 315, 205, 282, 482, 385, 899, 546, 108, 298, 79, 217, 359,
                927, 536, 164, 136, 759, 620, 758, 553, 941, 762, 518, 21, 613, 410, 858, 155, 802, 432, 222, 469,
                989, 504, 951, 727, 755, 849, 187, 54, 281, 404, 765, 208, 940, 281, 696, 51, 901, 807, 956, 842,
                921, 826, 215, 535, 236, 425, 690, 390, 857, 265, 859, 199, 121, 162, 926, 877, 364, 113, 283, 645,
                870, 48, 205, 162, 329, 902, 566, 582, 709, 522, 776, 630, 349, 991, 165, 937, 416, 208, 680, 626,
                825, 539, 825, 946, 54, 103, 175, 418, 568, 458, 415, 438, 858, 620, 953, 539, 874, 519, 121, 935,
                41, 897, 918, 742, 240, 435, 680, 9, 995, 360, 635, 820, 251, 812, 119, 305, 267, 294, 75, 835, 105,
                490, 626, 963, 463, 931, 855, 689, 450, 976, 625, 491, 226, 895, 586, 818, 330, 618, 827, 326, 330,
                462, 146, 581, 626, 265, 239, 893, 912, 314, 81, 17, 157, 59, 332, 972, 990, 539, 661, 440, 516, 638,
                283, 94, 533, 221, 912, 216, 839, 92, 542, 169, 554, 40, 103, 533, 658, 694, 778, 570, 8, 211, 939,
                517, 270, 623, 841, 612, 163, 855, 404, 31, 845, 40, 477, 731, 261, 741, 947, 101, 833, 841, 622, 740,
                881, 77, 273, 539, 771, 51, 461, 780, 263, 752, 649, 885, 728, 843, 850, 891, 698, 254, 274, 543, 294,
                751, 274, 556, 492, 573, 9, 326, 414, 631, 66, 296, 709, 691, 187, 480, 94, 1, 612, 709, 105, 614, 595,
                833, 457, 445, 76, 507, 51, 350, 50, 346, 453, 677, 902, 946, 250, 263, 624, 665, 246, 42, 313, 955,
                733, 852, 788, 827, 205, 752, 537, 311, 718, 484, 144, 175, 281, 573, 682, 332, 923, 85, 678, 729, 114,
                932, 675, 364, 195, 651, 381, 442, 693, 46, 749, 778, 251, 889, 957, 456, 994, 494, 767, 712, 330,
                264, 240, 611, 189, 274, 296, 464, 359, 326, 193, 825, 259, 868, 542, 806, 871, 275, 600, 916, 322,
                702, 694, 573, 591, 652, 381, 937, 498, 501, 650, 829, 117, 890, 792, 306, 164, 440, 770, 876, 767,
                964, 701, 378, 184, 243, 184, 56, 519, 137, 324, 193, 839, 19, 118, 782, 23, 499, 720, 521, 0, 722,
                702, 469, 612, 847, 775, 128, 287, 898, 4, 406, 862, 58, 784, 398, 653, 321, 454, 172, 458, 779, 717,
                649, 150, 835, 783, 525, 687, 855, 398, 687, 577, 101, 509, 189, 300, 284, 670, 939, 182, 674, 346,
                396, 84, 482, 795, 738, 803, 601, 910, 613, 732, 980, 614, 882, 815, 398, 407, 502, 253, 806, 542,
                831, 259, 51, 372, 911, 687, 42, 202, 870, 69, 900, 266, 153, 383, 413, 891, 538, 15, 154, 152, 747,
                134, 766, 982, 301, 516, 741, 804, 770, 547, 698, 953, 158, 749, 325, 421, 436, 720, 624, 658, 789,
                524, 277, 294, 907, 690, 538, 446, 57, 44, 950, 805, 178, 68, 787, 831, 585, 528, 987, 355, 428, 685,
                308, 938, 786, 985, 360, 575, 705, 984, 233, 846, 860, 862, 493, 768, 905, 31, 566, 962, 427, 868,
                767, 605, 936, 906, 788, 521, 787, 776, 228, 215, 461, 888, 153, 248, 874, 865, 823, 931, 849, 408,
                130, 710, 623, 975, 830, 528, 6, 748, 490, 785, 968, 610, 390, 904, 516, 530, 778, 303, 306, 358,
                870, 768, 247, 376, 368, 473, 241, 543, 756, 443, 303, 238, 505, 926, 213, 687, 454, 571, 435, 945,
                356, 403, 555, 98, 659, 423, 629, 789, 727, 935, 500, 949, 55, 99, 325, 775, 924, 567, 318, 680, 10,
                622, 919, 515, 548, 132, 202, 355, 704, 989, 652, 60, 744, 559, 159, 755, 982, 140, 897, 61, 75, 397,
                11, 131, 496, 336, 906, 420, 255, 577, 452, 265, 551, 371, 132, 451, 856, 686, 806, 912, 675, 810,
                324, 771, 369, 835, 527, 352, 975, 424, 765, 51, 173, 128, 534, 669, 817, 792, 441, 72, 721, 893,
                690, 272, 265, 822, 724, 473, 509, 882, 385, 536, 693, 709, 660, 62, 545, 187, 766, 872, 963, 884,
                923, 136, 12, 809, 157, 829, 602, 598, 902, 675, 843, 592, 948, 108, 766, 24, 933, 627, 906, 670,
                516, 951, 732, 176, 14, 277, 715, 132, 149, 30, 16, 425, 518, 29, 586, 675, 210, 188, 625, 112,
                216, 468, 56, 164, 929, 823, 188, 862, 802, 446, 885, 318, 398, 617, 494, 764, 894, 209, 896,
                395, 591, 913, 172, 109, 294, 759, 136, 504, 299, 761, 969, 515, 582, 25, 31, 511, 200, 571, 725,
                3, 18, 610, 321, 416, 227, 168, 180, 473, 729, 428, 221, 321, 693, 745, 430, 987, 504, 919, 844,
                156, 680, 165, 23, 262, 542, 55, 125, 743, 626, 203, 98, 996, 813, 771, 764, 393, 291, 296, 218,
                21, 725, 439, 694, 418, 537, 476, 758, 393, 395, 602, 549, 76, 767, 925, 690, 309, 332, 168, 404,
                310, 371, 854, 307, 536, 626, 71, 929, 917, 368, 148, 290, 445, 939, 984, 863, 476, 461, 621, 870,
                856, 575, 771, 284, 694, 48, 327, 356, 380, 495, 760, 691, 866, 967, 998, 402, 593, 421, 684, 862,
                141, 184, 153, 586, 123, 489, 450, 952, 950, 423, 174, 159, 351, 297, 443, 45, 346, 770, 401, 726,
                265, 514, 417, 483, 833, 767, 238, 426, 189, 922, 640, 682, 106, 145, 269, 581, 635, 71, 533, 585,
                494, 59, 744, 845, 357, 540, 243, 703, 662, 996, 429, 280, 510, 199, 763, 343, 966, 1, 121, 507, 923,
                114, 190, 381, 259, 811, 963, 894, 882, 848, 480, 728, 908, 576, 574, 265, 468, 169, 968, 131, 165,
                749, 763, 28, 948, 526, 723, 267, 880, 197, 774, 155, 311, 316, 537, 570, 127, 852, 465, 361, 700,
                297, 90, 608, 225, 16, 873, 694, 185, 193, 177, 350, 943, 940, 730, 243, 818, 454, 510, 50, 651,
                637, 206, 962, 305, 95, 884, 433, 299, 349, 146, 999, 646, 236, 960, 872, 604, 833, 918, 789, 379,
                95, 492, 322, 387, 222, 917, 205, 28, 428, 256, 31, 65, 814, 993, 722, 909, 878, 507, 208, 579,
                654, 559, 578, 890, 519, 450, 847, 705, 720, 636, 84, 815, 480, 758, 202, 55, 675, 759, 83, 455,
                15, 115, 872, 829, 460, 595, 90, 690, 102, 650, 270, 756, 210, 848, 999, 81, 650, 846, 786, 370,
                834, 222, 537, 315, 980, 91, 370, 8, 850, 805, 463, 218, 272, 336, 399, 85, 283, 842, 775, 385,
                492, 397, 494, 54, 597, 493, 488, 599, 691, 274, 321, 525, 497, 210, 192, 829, 301, 914, 837, 504,
                72, 653, 74, 344, 341, 825, 429, 624, 667, 557, 9, 512, 306, 855, 918, 904, 700, 406, 503, 391,
                33, 825, 269, 530, 35, 813, 711, 689, 80, 901, 545, 152, 554, 619, 848, 895, 444, 630, 519, 464,
                187, 880, 976, 493, 736, 246, 749, 436, 653, 253, 180, 686, 430, 801, 568, 817, 614, 631, 858,
                694, 532, 403, 846, 86, 374, 47, 333, 171, 677, 204, 635, 864, 437, 963, 709, 173, 209, 459, 961,
                214, 64, 493, 252, 494, 294, 172, 663, 261, 804, 522, 955, 336, 277, 154, 775, 652, 201, 460, 823,
                878, 665, 458, 94, 102, 773, 155, 627, 982, 614, 940, 197, 678, 434, 801, 524, 80, 974, 540, 341,
                778, 414, 297, 466, 691, 803, 593, 695, 4, 54, 518, 234, 71, 328, 680, 173, 453, 835, 152, 436,
                802, 92, 985, 480, 526, 786, 357, 959, 112, 249, 300, 890, 663, 597, 709, 706, 752, 302, 402, 756,
                356, 272, 342, 427, 953, 22, 952, 406, 210, 104, 194, 12, 197, 531, 844, 75, 670, 201, 386, 782,
                802, 687, 25, 817, 636, 734, 524, 389, 388, 278, 497, 97, 902, 192, 876, 855, 214, 829, 614, 776,
                285, 160, 788, 834, 44, 633, 262, 66, 186, 648, 200, 989, 335, 225, 158, 972, 311, 682, 713, 700,
                960, 210, 797, 215, 402, 673, 422, 969, 854, 36, 745, 140, 549, 886, 974, 945, 519, 236, 11, 57,
                885, 211, 398, 572, 789, 557, 896, 100, 591, 609, 152, 552, 820, 949, 119, 574, 975, 541, 895, 181,
                578, 993, 321, 479, 879, 648, 424, 750, 236, 787, 159, 473, 998, 558, 46, 787, 467, 942, 240, 58,
                552, 392, 962, 724, 694, 81, 650, 21, 623, 546, 202, 553, 539, 876, 384, 770, 524, 808, 520, 760,
                947, 31, 234, 945, 589, 632, 85, 408, 574, 677, 467, 478, 69, 429, 554, 115, 863, 205, 136, 486, 103,
                339, 391, 994, 567, 775, 764, 91, 935, 636, 203, 882, 667, 789, 179, 609, 421, 616, 17, 348, 293,
                484, 178, 715, 266, 733, 830, 129, 938, 319, 967, 393, 10, 358, 387, 577, 485, 151, 668, 420, 139,
                871, 302, 806, 13, 833, 767, 434, 450, 785, 134, 95, 621, 313, 810, 887, 46, 641, 368, 336, 312,
                335, 729, 322, 45, 468, 899, 530, 971, 567, 950, 110, 790, 604, 268, 803, 790, 36, 590, 592, 821,
                76, 687, 794, 389, 498, 682, 787, 491, 402, 475, 803, 90, 556, 125, 135, 24, 376, 18, 995, 943,
                320, 105, 85, 277, 374, 241, 67, 762, 183, 659, 583, 259, 346, 377, 1, 196, 411, 788, 687, 166,
                616, 842, 256, 172, 319, 391, 549, 695, 761, 544, 990, 82, 2, 428, 359, 728, 669, 426, 490, 204,
                437, 425, 463, 783, 154, 816, 332, 918, 605, 19, 84, 573, 214, 340, 745, 885, 83, 294, 581, 845,
                191, 923, 927, 545, 351, 638, 625, 20, 64, 467, 576, 501, 892, 40, 636, 398, 856, 968, 668, 813,
                340, 752, 738, 906, 444, 484, 791, 880, 130, 372, 77, 673, 296, 356, 570, 999, 994, 195, 20, 58,
                662, 596, 911, 906, 988, 899, 305, 197, 868, 325, 362, 560, 78, 101, 466, 874, 937, 609, 106, 419,
                982, 183, 445, 630, 539, 15, 981, 533, 211, 1, 943, 873, 950, 854, 780, 290, 106, 437, 839, 326,
                762, 202, 886, 192, 655, 704, 419, 944, 313, 525, 363, 647, 709, 808, 629, 248, 176, 611, 782,
                387, 964, 725, 612, 266, 932, 392, 909, 390, 181, 748, 716, 944, 302, 954, 136, 309, 658, 907,
                253, 323, 433, 969, 323, 142, 129, 952, 390, 305, 915, 524, 692, 232, 602, 305, 498, 534, 49,
                759, 924, 231, 508, 992, 175, 162, 946, 663, 472, 604, 923, 77, 279, 356, 46, 602, 498, 176, 907,
                240, 481, 174, 765, 526, 406, 367, 183, 257, 253, 232, 16, 177, 815, 876, 521, 342, 39, 467, 358,
                863, 423, 281, 940, 702, 637, 339, 657, 135, 515, 916, 727, 348, 90, 492, 226, 497, 859, 409, 106,
                112, 994, 122, 641, 809, 351, 162, 152, 742, 981, 510, 605, 404, 143, 897, 459, 780, 236, 116, 267,
                103, 32, 994, 804, 474, 487, 30, 323, 698, 792, 429, 163, 138, 904, 156, 947, 607, 671, 451, 349, 652,
                313, 306, 57, 456, 555, 868, 588, 144, 984, 855, 599, 368, 202, 403, 194, 689, 786, 518, 739, 930, 299,
                902, 68, 555, 59, 367, 162, 82, 819, 863, 734, 484, 169, 143, 293, 725, 11, 881, 869, 347, 89, 468, 67,
                291, 224, 262, 332, 362, 132, 71, 292, 783, 326, 360, 339, 737, 79, 501, 819, 250, 365, 905, 735, 886,
                49, 380, 963, 412, 261, 184, 760, 702, 653, 179, 993, 229, 793, 677, 591, 925, 749, 883, 61, 75, 595,
                400, 164, 26, 253, 983, 277, 970, 888, 12, 857, 289, 744, 820, 702, 357, 5, 814, 60, 10, 993, 405, 591,
                139, 83, 182, 64, 832, 417, 477, 259, 364, 877, 423, 390, 131, 758, 667, 453, 998, 31, 310, 288, 775,
                483, 342, 133, 840, 156, 545, 850, 501, 950, 441, 640, 33, 975, 57, 865, 392, 534, 476, 108, 764, 251,
                498, 895, 361, 518, 348, 360, 549, 11, 0, 677, 494, 694, 162, 686, 850, 707, 536, 703, 657, 329, 344,
                691, 656, 753, 908, 400, 287, 385, 508, 403, 988, 358, 298, 350, 876, 999, 62, 426, 362, 414, 103,
                856, 108, 265, 894, 310, 324, 430, 13, 981, 111, 709, 672, 119, 814, 581, 519, 454, 318, 27, 857,
                658, 385, 156, 8, 262, 507, 422, 40, 869, 836, 495, 77, 296, 112, 971, 606, 436, 753, 972, 417, 216,
                33, 442, 335, 848, 375, 854, 302, 693, 233, 159, 703, 970, 667, 64, 584, 526, 486, 624, 747, 675,
                471, 824, 971, 583, 147, 930, 19, 900, 902, 789, 468, 935, 231, 803, 783, 606, 9, 437, 651, 242, 949,
                354, 565, 616, 770, 149, 495, 257, 126, 242, 932, 597, 67, 255, 181, 566, 185, 552, 467, 87, 693,
                287, 375, 924, 91, 510, 882, 100, 948, 885, 695, 897, 592, 260, 865, 362, 761, 360, 971, 887, 603,
                903, 837, 22, 511, 18, 588, 696, 922, 407, 136, 616, 695, 511, 892, 138, 21, 127, 590, 969, 12, 285,
                218, 956, 897, 84, 319, 11, 796, 290, 898, 751, 546, 735, 773, 409, 105, 714, 105, 380, 121, 241,
                348, 168, 752, 592, 306, 126, 719, 897, 447, 84, 534, 666, 40, 784, 102, 711, 795, 250, 354, 45, 2,
                252, 133, 127, 661, 238, 841, 766, 970, 315, 360, 318, 483, 464, 911, 142, 590, 982, 391, 38, 66,
                925, 56, 459, 709, 510, 170, 856, 760, 524, 902, 762, 776, 35, 242, 437, 625, 83, 556, 596, 398,
                916, 266, 234, 380, 177, 376, 323, 160, 767, 361, 578, 44, 769, 37, 106, 279, 208, 962, 391, 84,
                216, 506, 861, 603, 748, 650, 229, 183, 558, 177, 582, 474, 443, 168, 207, 621, 896, 530, 133, 15,
                243, 711, 411, 12, 749, 517, 643, 309, 832, 34, 393, 400, 892, 606, 4, 640, 609, 585, 824, 167,
                762, 758, 994, 557, 278, 201, 530, 174, 731, 663, 541, 974, 727, 952, 338, 828, 822, 981, 137, 6,
                367, 882, 406, 260, 841, 762, 900, 450, 347, 76, 969, 461, 186, 963, 19, 464, 164, 549, 990, 895,
                565, 531, 221, 292, 836, 559, 472, 658, 540, 609, 664, 260, 843, 422, 520, 684, 185, 772, 486, 884,
                849, 456, 346, 35, 419, 717, 852, 936, 618, 842, 183, 183, 374, 405, 827, 210, 316, 299, 220, 209,
                260, 236, 469, 456, 658, 989, 140, 195, 113, 979, 80, 962, 435, 778, 350, 206, 847, 202, 494, 465,
                44, 678, 1, 770, 435, 180, 332, 751, 832, 904, 960, 92, 140, 781, 548, 151, 770, 41, 346, 236, 20,
                778, 550, 807, 908, 900, 365, 755, 454, 860, 573, 851, 890, 926, 621, 325, 106, 306, 76, 938, 210,
                389, 383, 703, 170, 283, 206, 293, 324, 904, 529, 696, 683, 79, 855, 943, 332, 221, 51, 786, 433,
                624, 989, 323, 550, 963, 648, 8, 269, 76, 947, 831, 817, 682, 886, 340, 965, 92, 633, 642, 997, 514,
                338, 32, 945, 194, 975, 277, 767, 378, 416, 200, 2, 405, 875, 904, 720, 875, 265, 341, 951, 212, 173,
                121, 246, 411, 461, 211, 504, 446, 853, 853, 960, 544, 237, 257, 90, 564, 535, 857, 943, 303, 409,
                945, 60, 636, 202, 781, 511, 467, 122, 814, 31, 647, 935, 277, 59, 748, 840, 915, 194, 46, 768, 506,
                590, 5, 764, 680, 569, 299, 889, 512, 954, 650, 810, 14, 286, 364, 147, 797, 831, 622, 611, 862, 269,
                899, 491, 680, 647, 331, 595, 842, 377, 715, 348, 319, 72, 464, 351, 642, 115, 592, 506, 69, 242,
                668, 436, 880, 32, 583, 29, 215, 557, 993, 77, 827, 244, 920, 859, 891, 604, 807, 85, 333, 522, 786,
                653, 595, 250, 4, 589, 366, 949, 447, 787, 543, 468, 223, 424, 500, 159, 805, 716, 716, 798, 145, 895,
                42, 418, 107, 286, 22, 914, 371, 355, 436, 157, 8, 383, 760, 365, 324, 478, 666, 124, 265, 209, 592,
                841, 985, 444, 0, 791, 160, 68, 941, 658, 316, 336, 76, 423, 622, 450, 337, 345, 805, 773, 855, 166,
                509, 615, 883, 833, 93, 549, 957, 710, 758, 901, 551, 96, 346, 903, 887, 858, 972, 828, 516, 288, 516,
                944, 711, 138, 394, 48, 484, 552, 173, 691, 718, 34, 306, 601, 220, 751, 502, 529, 461, 612, 431, 13,
                708, 777, 916, 947, 635, 240, 776, 504, 528, 644, 800, 591, 783, 547, 991, 619, 99, 517, 310, 169, 551,
                968, 122, 771, 719, 624, 653, 532, 588, 84, 897, 297, 213, 814, 244, 200, 406, 372, 56, 287, 17, 209,
                878, 152, 756, 870, 123, 855, 387, 433, 376, 290, 753, 498, 414, 824, 122, 67, 356, 62, 503, 254, 359,
                68, 420, 956, 268, 826, 680, 677, 113, 697, 886, 992, 201, 642, 214, 324, 849, 953, 109, 225, 595,
                862, 723, 9, 686, 197, 428, 43, 259, 283, 649, 971, 351, 69, 927, 620, 247, 959, 649, 361, 657, 535,
                705, 210, 177, 271, 535, 378, 224, 644, 603, 171, 859, 678, 181, 545, 875, 961, 940, 486, 245, 589,
                809, 596, 10, 736, 568, 258, 48, 217, 971, 705, 752, 676, 267, 281, 947, 802, 659, 523, 799, 614,
                694, 658, 292, 227, 555, 519, 541, 496, 6, 786, 437, 815, 734, 448, 904, 303, 58, 952, 872, 29, 9,
                625, 57, 276, 258, 356, 431, 918, 879, 230, 884, 925, 240, 177, 505, 795, 696, 46, 291, 54, 832,
        }));
    }

    public int minMoves(int[] nums) {
        int res = 0;
        Arrays.sort(nums);
        for (int num : nums) {
            res += num - nums[0];
        }
        return res;
    }
}
